home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 24 / Commodore_Free_Issue_24_2008_Commodore_Computer_Club.d64 / t.b guide 9.2 < prev    next >
Text File  |  2023-02-26  |  11KB  |  369 lines

  1. u
  2. In the Beginning Chaper 9, Section 2
  3. Lord Ronin from Q-Link
  4.  
  5.  
  6.  Tip for you here, you will see that
  7. after 127. Things start showing up in
  8. reverse video. If you know the code
  9. for a symbol, just add 128 to that
  10. code number and it will be in reverse
  11. video.
  12.  
  13.  Two areas are used in the computer
  14. memory. For creating the symbol and
  15. the colour on the screen. Meaning that
  16. a block of memory from 1024 to 2023 is
  17. for the screen. Colour is from 55296
  18. to 56295. Yuppers another block of
  19. memory for the colour that appears on
  20. the screen.
  21.  
  22.  In the above poke stuff to place the
  23. ball on the screen and to change the
  24. balls colour. Two poke codes where
  25. used. One to place the ball and the
  26. other to place the colour for the ball
  27. in the right place.
  28.  
  29.  Saying that in a couple of ways. You
  30. can guess that there is probably
  31. another 1000 square grid map. Right,
  32. there is and the top left part starts
  33. at 55296, and at the bottom right ends
  34. at 56295. Before I go farther, it
  35. should be stated that these areas, the
  36. blocks of numbers can be called memory
  37. locations. There are books that have
  38. what is called the memory maps in
  39. them, where you can see more about the
  40. locations, including some ideas of
  41. what is in there and what can be done
  42. with those areas. This is something
  43. that I am not skilled in, or
  44. understand. I know that it is
  45. important in Basic and it is important
  46. in the Machine Language <ML> form of
  47. programming. We aren't going there in
  48. this series. Just wanted to give you a
  49. heads up on this, as you may be
  50. interested in going farther in
  51. programming than Basic and this little
  52. personal look at the users manual.
  53.  
  54.  Feel free to make a grid for the
  55. Colour Memory Map. Same as what we
  56. talked about for the Screen one.
  57. Numbers on the left hand side of the
  58. map. Going down the rows, starts at
  59. row 0 and ending at row 24. Goes like
  60. this, start is 55296 for row 0 column
  61. 0. Row 24 column 0 is 56256. Row 0
  62. column 39 is 55335. Spending some time
  63. with these coordinates. You can make
  64. the grid map. Naturally there is the
  65. lazy way to figure out where you want
  66. to put the colour on the screen. Yeah
  67. I am still lazy. <VBG>
  68.  
  69. COLOUR POINT = 55296 + X +40*Y
  70.  
  71.  Sure looks familiar doesn't it? <G>
  72. the only change is that of the
  73. starting point number. Matching the
  74. top left corner of the colour memory
  75. map grid. So yeah if you retro fit
  76. that above poke thing to put the
  77. colour into column 20 and row 12 it
  78. would look like...
  79.  
  80. COLOUR POINT = 55296 + 20 + 40*12
  81. COLOUR POINT = 55296 + 20 + 480
  82. COLOUR POINT = 55796
  83.  
  84.  Poke that in and add the colour of
  85. 0-15 spectrum and you have coloured
  86. the character you put at that memory
  87. location. Might seem that this is a
  88. bit of work. At this point it is for
  89. us. Gets better with time and other
  90. things. OK I doubt that with some
  91. tools you can use for making
  92. programmes. Well you may not be doing
  93. this form of math out all the time if
  94. at all. Just see how much hands on
  95. control of things you have with your
  96. ideas for your programmes!
  97.  
  98.  So then let us clear the screen and
  99. prepare for typing in another
  100. programme. I'm modifying this one for
  101. us. Just a little colour change from
  102. what the book says. Personal taste
  103. here and you should feel free to alter
  104. the colours to it what looks the best
  105. to you. We will be putting in a symbol
  106. here as well, for screen display,
  107. again feel free to alter that to
  108. something else.
  109.  
  110.  new
  111.  
  112. 10 ?"<shift clear/home>"
  113. 20 pO53280,0:pO53281,0
  114. 30 x=1:y=1
  115. 40 dx=1:dy=1
  116. 50 pO1024+x+40*y,81
  117. 60 fort=1to10:next
  118. 70 pO1024+x+40*y,32
  119. 80 x=x+dx
  120. 90 ifx<=0orx>=39thendx=-dx
  121. 100 y=y+dy
  122. 110 ify<=0ory>=24thendy=-dy
  123. 120 goto50
  124.  
  125.  Done most of this already in
  126. different forms, still let us go over
  127. the lines. If you haven't run this
  128. programme yet, this is another
  129. bouncing ball programme. This one
  130. though is different; this version
  131. bounces the ball all over the screen,
  132. being redirected as the ball hits the
  133. border. Sort of like a pool ball.
  134. Which causes me to remember that there
  135. are pool games and pinball games for
  136. the C=. This little thing you typed in
  137. is a far cry from that level of
  138. programming. Still though it is the
  139. same sort of principal and shows you
  140. some animation.
  141.  
  142.  Line 10 is easy to understand. In
  143. fact the book wants you to type it in
  144. that way. I didn't alter that line
  145. from the chr$(147). They didn't use
  146. that command in this one.
  147.  
  148.  Line 20 is also easy to understand
  149. after what we have done. Changes the
  150. screen and border colour. OK I did the
  151. short hand code for the poke command.
  152. Also I changed the colours to make the
  153. screen and the border black. Book
  154. colours are 7 for the border and 13
  155. for the screen. Light green screen and
  156. a yellow border.
  157.  
  158.  Line 30 is a variable set up. Set
  159. here to keep track of the row and
  160. column position of the ball.
  161.  
  162. Line 40. DX & DY are variables; they
  163. are also the horizontal and vertical
  164. directions of the balls movements. Hey
  165. don't worry if that doesn't sink into
  166. your mind at this time, it doesnt for
  167. me either. Exactly how that works,
  168. point for point is magic to me.
  169.  
  170. Line 50 is recently familiar. Note
  171. that it is the poke code and formula
  172. to put the ball character onto the
  173. screen. A few things to see here. See
  174. that ,81 part at the far end of the
  175. line. Remembering that previous thing
  176. about putting the ball on the screen?
  177. That was the ,81 remember? Note though
  178. that the formula is the same frelling
  179. thing as this programme line, meaning
  180. that you don't have to figure out the
  181. numbers for the screen placement, this
  182. line does that for you. Using the
  183. existing variables for X and Y. But
  184. see that the 1024 is at the start as
  185. its in the formula. Well when you run
  186. this programme. You will see that the
  187. ball starts out at the top left of the
  188. screen. Goes to the bottom right and
  189. bounces around the screen.
  190.  
  191.  At line 60 there is the for next
  192. loop, producing a short time delay.
  193. Here is something to notice. Remember
  194. that 2000 we had in the screen and
  195. border change? Here it is a delay of
  196. 10. Obviously a much shorter delay.
  197. Here is a lesson not discussed in the
  198. book. Setting the delay for your
  199. programme. Can't really help you on
  200. this part. I can Only say that you may
  201. need to adjust the time delay to fit
  202. yourself and other people. If you find
  203. this 1 to10 one a bit too flickery of
  204. the image of the ball. Try adding to
  205. the number or shortening it to a
  206. smaller value.
  207.  
  208. Looking at Line 70 we see the same
  209. smegging screen point formula. Again
  210. it is doing all the work for you in
  211. the placement of the ball on the
  212. screen. Except you see that ,32 at the
  213. end. Above I stated in the part where
  214. you where playing with the numbers for
  215. different symbols. Said there that
  216. this 32 was one of the two numbers for
  217. the space. So then what is happening
  218. here is that the formula isn't putting
  219. the ball on the screen. In fact it is
  220. doing the opposite. Erasing the ball
  221. from the screen. REM this line and see
  222. what the programme does <VBG>.
  223.  
  224.  Next is Line 80 and this line is
  225. adding a direction factor to the X
  226. <vertical>. Taking us to line 90. You
  227. can see that this is an IF THEN
  228. statement. By a simple look the
  229. numbers are 0 and 39 in this line. Hmm
  230. that happens to be the designation
  231. numbers of the 40 columns or the X
  232. factor in this programme. As you see
  233. if X is less than or equal to 0, the
  234. left hand side of the screen. Or it is
  235. greater than or equal to 39, the right
  236. hand side of the screen. That value of
  237. DX suddenly becomes negative with the
  238. value of -DX. Or better said, that
  239. makes the ball bounce off of the sides
  240. of the screen.
  241.  
  242.  Next line is line100 and that looks a
  243. bit like line 80. Hey line 110 looks a
  244. bit like line 90. Save for the fact
  245. that this is the Y part. Or the top
  246. and bottom of the screen. Making the
  247. ball bounce. You can bugger this up a
  248. bit by altering the DX and the DY.
  249. Tell you that one member made a
  250. mistype and that made the ball just go
  251. back and forth on the 0 row.
  252.  
  253.  Well that looks real nice, and it is
  254. an amazing thing to do when you type
  255. it in the first time. Remember that
  256. you did this yourself. This is your
  257. creation. Alter it a bit with a symbol
  258. of your choice. Personally I used the
  259. "\" symbol for the ball.
  260.  
  261.  Not finished with this one yet. Here
  262. are some lines to add to the
  263. programme.
  264.  
  265. 21 forL=1to10
  266. 25 pO1024+int(rnd(1)*1000),166
  267. 27 nextL
  268. 85 ifpeek(1024+x+40*y)=166thendx=-dx
  269. 100ifpeek(1024+x+40*y)=166thendy=-dy
  270.  
  271.  This does a what? Some of it looks
  272. familiar; some of it looks real
  273. familiar.
  274.  
  275. First new is a stock for part of a for
  276. next loop. Here I intentionally used
  277. the upper case L as one of the
  278. problems in typing things in from a
  279. book is the confusion of a 1 and a l.
  280. Ok and 0 vs. O as well. Type face or
  281. more commonly they are called fonts.
  282. Are confusing in the books. As it just
  283. don't look like what is on the screen
  284. in the C= font.
  285.  
  286. Saying that we see that there is only
  287. 10 things. We see also that the NEXT
  288. part of this loop is in line 27. So
  289. then what ever happens in that line 25
  290. is done 10 times. As we know it is
  291. going to loop between these lines till
  292. all 10 things are done.
  293.  
  294. Line 25 sort of looks like the thing
  295. that puts the symbol on the screen. At
  296. least it starts out that way. But we
  297. are then tossed into a different form
  298. of a random number generator and there
  299. are 1000 things? This is what is
  300. happening on this line. Each time it
  301. is run, and that is 10 times from the
  302. for-next loop. One location out of the
  303. 1000 possible locations is going to be
  304. generated and is going to be added to
  305. the base number of 1024. Meaning that
  306. this is a line to create something on
  307. the screen at purely random locations.
  308. At the end of the line is that ,166
  309. code. That is the symbol. Ok this
  310. means that the programme will go 10
  311. times through this for next loop.
  312. Generating a screen location and
  313. putting in that location the symbol
  314. for 166. IIRC that is the reverse
  315. video & symbol. I change it each time
  316. I play with the programme. Looks
  317. better if it is the reverse video.
  318. Remember about adding 128 to the code
  319. number to get the reverse video of the
  320. character.
  321.  
  322.  On the screen will be these 10
  323. symbols. OK so that is nice and what
  324. will that mean? Take a look at line 85
  325. and then at line 105. Look a bit
  326. familiar from a couple of lines in
  327. this programme already? Right, the
  328. difference is the 166 code number. If
  329. this line works like the ones for the
  330. four sides of the screen, then this
  331. must look for that code numbered
  332. symbol on the screen as well, and it
  333. will do the same thing. As you see by
  334. the fact the variable becomes a
  335. negative number. Run it and you have
  336. 10 obstacles on the screen, that will
  337. make the ball bounce off of the sides
  338. of the screen and off of these
  339. symbols. Play around with the symbols
  340. and the number of obstacles to see
  341. what you can create. Don't worry about
  342. the colour at this time. If you think
  343. you can figure out how to make the
  344. colour of the ball different from the
  345. obstacles then feel free to give it a
  346. shot. Not really needed at this time.
  347. Good experimentation though.
  348.  
  349.  Next we move into sprites and a lot
  350. of difficulty in trying to paint a
  351. word picture of what is going on.
  352.  
  353.  The reason for that statement is
  354. simply that there are some graph
  355. charts in the book. These charts are
  356. drawn in a way that I am not at the
  357. least bit certain I can recreate them
  358. in my word writing programme. I'll
  359. give it my best shot. Hopefully I can
  360. illustrate with words, what I can't
  361. illustrate with the graphics.
  362.  
  363.  Good news for you is that there isn't
  364. enough space in this instalment to go
  365. into the details of sprites. We will
  366. pick it up in the next session.
  367.  
  368. ====
  369.